public class Test1 {
    static class animanals{
        protected String name;
        animanals(String name){
            this.name=name;
        }
        public void Sleep(){}
        public void Speak(){}
    }

    static class Dog extends animanals{
        Dog(String name){
            super(name);
        }

        public void Sleep(){
            System.out.println("狗的睡觉方式");
        }
        public void Speak(){
            System.out.println("狗的吼叫方式");
        }
    }

    static class Cat extends animanals{
        Cat(String name){
            super(name);
        }

        public void Sleep(){
            System.out.println("猫的睡觉方式");
        }
        public void Speak(){
            System.out.println("猫的吼叫方式");
        }
    }

    public static void main(String[] args) {
        animanals dog=new Dog("旺财");
        dog.Sleep();
        dog.Speak();
        animanals cat=new Cat("汤姆");
        cat.Sleep();
        cat.Speak();
    }
}
